package win.doyto.service.data.config;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.Getter;
import lombok.Setter;
import win.doyto.query.entity.CommonEntity;
import win.doyto.query.util.BeanUtil;

import javax.persistence.Table;

/**
 * ReportConfig
 *
 * @author f0rb on 2018-03-01.
 */
@Getter
@Setter
@Table(name = "core_report_config")
@SuppressWarnings("unused")
public class ReportConfigEntity extends CommonEntity<Integer, Integer> {

    private String reportKey;

    private String reportName;

    private String reportSql;

    private ReportParam reportParam;

    public ReportParam reportParam() {
        return reportParam;
    }

    public String getReportParam() {
        return reportParam == null ? null : JSON.toJSONString(reportParam);
    }

    public void setReportParam(String reportParam) {
        this.reportParam = BeanUtil.parse(reportParam, new TypeReference<ReportParam>() {});
    }

}
